mini.parse();
var projectName = $("#projectName").val();
var form = new mini.Form("form1");

function SaveDataOffLanguageZhCn() {
	form.validate();
	if (form.isValid() == false)
		return;
	$("#form1").ajaxSubmit({
		type: "POST",
		url:projectName+"/OffLanguageZhCnAdmin/saveOffLanguageZhCn",
		dataType: "json",
	    success: function(data){
	    	if (data.status == '1') {
				mini.alert(data.message, "" , function() {
					CloseWindowOffLanguageZhCn("save");
				});
			} else if(data.status == '0') {
				mini.alert(data.message);
			} else {
				mini.alert("发生错误!");
			}
		}
	});
	
}

////////////////////
//标准方法接口定义
function CheckEventOffLanguageZhCn(data) {
//跨页面传递的数据对象，克隆后才可以安全使用
	data = mini.clone(data);
	if (data.action == "edit") {
		SetDataOffLanguageZhCn(data);
	} else if (data.action == "new") {
	}else if(data.action =="look"){
		SetDataOffLanguageZhCn(data);
		readOnlyForm();
	}
}

function GetDataOffLanguageZhCn(){
	var o = form.getData();
	return o;
}
function SetDataOffLanguageZhCn(data){
		$.ajax({
			url : projectName+"/OffLanguageZhCnAdmin/queryByID?id="
					+ data.id,
			cache : false,
			success : function(text) {
				var o = mini.decode(text);
				form.setData(o);
				$("#imageId").attr("src",projectName+"/"+o.pictureUrl);
				form.setChanged(false);
			}
			});
}
function CloseWindowOffLanguageZhCn(action) {
	if (action == "close" && form.isChanged()) {
		if (confirm("数据被修改了，是否先保存？")) {
			return false;
		}
	}
	if (window.CloseOwnerWindow)
		return window.CloseOwnerWindow(action);
	else
		window.close();
}
function onOkOffLanguageZhCn(e) {
	SaveDataOffLanguageZhCn();
}
function onCancelOffLanguageZhCn(e) {
	CloseWindowOffLanguageZhCn("cancel");
}

function labelModel() {
	var fields = form.getFields();
	for ( var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly)
			c.setReadOnly(true); //只读
		if (c.setIsValid)
			c.setIsValid(true); //去除错误提示
		if (c.addCls)
			c.addCls("asLabel"); //增加asLabel外观
	}
}
function inputModel() {
	var fields = form.getFields();
	for ( var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly)
			c.setReadOnly(false);
		if (c.removeCls)
			c.removeCls("asLabel");
	}
	mini.repaint(document.body);
}
function readOnlyForm(){
	$("#button_okOffLanguageZhCn").hide();
	$("#button_onCancelOffLanguageZhCn").hide();
	form.setEnabled(false);
}
